package com.flyme.module.base.provider.service.impl;

import com.flyme.common.core.model.query.CriteriaQuery;
import com.flyme.core.base.supper.service.impl.BaseServiceImpl;
import com.flyme.module.base.client.entity.Sysenum;
import com.flyme.module.base.provider.mapper.SysenumMapper;
import com.flyme.module.base.provider.service.SysenumService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SysenumServiceImpl extends BaseServiceImpl<SysenumMapper, Sysenum> implements SysenumService {

    /**
     * 根据code查询枚举
     */
    @Override
    public Sysenum findByCode(String code) {
        return getOne(q().eq(true, "enumCode", code), false);
    }


    /**
     * 根据text查询枚举
     */
    @Override
    public Sysenum findByText(String text) {
        return getOne(q().eq(true, "enumName", text), false);
    }

    @Override
    public List<Map<String, Object>> findByType(String enumType) {
        CriteriaQuery<Sysenum> cq=new CriteriaQuery();
        cq.select("id value,enumName title,sortOrder,enumCode,id,enumName");
        cq.eq("enumType",enumType);
        cq.orderByAsc("sortOrder");
        return listMaps(cq);
    }


}
